<template>
  <div class="article">
    <van-nav-bar
      title="新闻详情页"
      left-text="返回"
      left-arrow
      @click-left="goBack"
      fixed
    >
    </van-nav-bar>
    <!-- 导航导航结束 -->
    <!-- 正文区域开始 -->
    <div class="question">
      <!-- 标题开始 -->
      <div class="question-header">
        <div class="question-header-title">
          {{ $store.state.new[id].title }}
        </div>
        <div class="question-header-datetime">
          {{ $store.state.new[id].src }}  {{ $store.state.new[id].time }}
        </div>
      </div>
      <!-- 标题结束 -->

      <!-- 内容开始 -->
      <div class="question-content">
        <div class="rich-content" v-html="$store.state.new[id].content"></div>
      </div>
      <!-- 内容结束 -->
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      // article: [],
      id:0,
    };
  },
  mounted() {
    // /article?id=237
    this.id = this.$route.params.id;
    // this.article = $store.state.new;
    console.log(this.id);
    // console.log(this.article);
  },
  methods: {
    goBack() {
      this.$router.go(-1);
    },
  },
};
</script>

<style>
.article .van-nav-bar {
  color: white;
  background-color: rgb(123, 183, 253);
}
.article .van-nav-bar__title,
.article .van-nav-bar__left i,
.article .van-nav-bar__left span {
  color: white;
}

.article {
  background: #f6f6f6;
  height: 100vh;
}
.question {
  margin-top: 46px;
}
.question-header {
  margin-bottom: 5px;
  padding: 10px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(26, 26, 26, 0.1);
}
.question-header-title {
  font-size: 18px;
  color: #1a1a1a;
  line-height: 1.5;
}
.question-header-datetime {
  margin-top: 5px;
  font-size: 14px;
  color: #646464;
}
.author-info {
  display: flex;
  align-items: center;
  margin-bottom: 5px;
  padding: 8px 10px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(26, 26, 26, 0.1);
}
.author-info-avatar {
  width: 40px;
  height: 40px;
  border-radius: 100%;
}
.author-info-detail {
  margin-left: 15px;
}
.author-info-nickname {
  font-size: 15px;
  margin-bottom: 6px;
}
.author-info-badge {
  font-size: 14px;
}
.question-content {
  padding: 10px;
  background-color: #fff;
}

.rich-content p {
  padding: 5px 0;
  line-height: 1.7;
}
.rich-content img {
  max-width: 100%;
}
</style>